var express = require('express');
var router = express.Router();
const mongodb= require('../components/mongodb');
var validate =  require('../components/validator');
var xlsx = require('xlsx');
const fs = require('fs');


/* GET home page. */
router.get('/', async(req, res)=> {
  console.log(req.query.data);
  const result = await mongodb.find("case",{});
  if(req.query.data){
  	  var qobj = JSON.parse(req.query.data);
	  var similar_case = validate.sortByScore(qobj,result);
	  res.json(similar_case.slice(0,3));
  }else{
	res.json(result.slice(0,20));
  }
  
  //随机返回
  
  
});

module.exports = router;
